# frozen_string_literal: true

module Ordinalable
  extend ActiveSupport::Concern
  included do
    include Sortable

    scope :ordinal_asc, -> { asc_by :ordinal }
    scope :ordinal_desc, -> { desc_by :ordinal }

    validates :ordinal,
              presence: true,
              numericality: {
                only_integer: true,
                greater_than_or_equal_to: 0
              }
  end
end
